{% extends "::base.html.twig" %}
{% block title %}{{ parent() }} - Utilisateurs{% endblock %}
{% block titre %}{{ parent() }} Gestion des utilisateurs{% endblock %}
{% block body %}

<div class="col_12">
    <div id="tabr1">
        {% for message in app.session.getFlashes() %}
        <div class="vert">
            <span class="icon small green" data-icon="C"></span> {{ message|trans }}
        </div>
        {% endfor %}
        <table>
        {% for user in users %}
            
                <tr>
                    <td><a href="{{ path('fos_user_presentation_trouver', { 'username': user.username }) }}">{{ user.username }}</a></td>
                    <td>{{ user.email }}</td>
                    <td>{{ user.nom }}</td>
                    <td>{{ user.prenom }}</td>
                    <td>{{ user.sexe }}</td>
                    <td>{{ user.ville }}</td>
                    <td>{{ user.codeP }}</td>
                    <td>
                        {% if user.username != app.user.username %}
                            {% if user.enabled == true %}
                                <button type="button" class="small red tooltip" title="Bannir" onclick="window.location='{{path("ProjetAAdminBundle_bannir", { 'username': user.username })}}'">
                                    <span class="icon small white" data-icon="r"></span>
                                </button>
                            {% else %}
                                <button type="button" class="small green tooltip" title="Autoriser" onclick="window.location='{{path("ProjetAAdminBundle_bannir", { 'username': user.username })}}'">
                                    <span class="icon small white" data-icon="q"></span>
                                </button>
                            {% endif %}
                        {% endif %}
                    </td>
                    <td>
                        {% if user.username != app.user.username %}
                            {% set var = false %}
                            {% for role in user.roles %}
                                {% if role == 'ROLE_ADMIN' %}
                                    {% set var = true %}
                                {% endif %}
                            {% endfor %}
                            {% if var %}
                                <button type="button" class="small orange tooltip" title="Changer le statut : Utilisateur" onclick="window.location='{{path("ProjetAAdminBundle_admin", { 'username': user.username })}}'">
                                    <span class="icon small white" data-icon="u"></span>
                                </button>
                            {% else %}
                                <button type="button" class="small blue tooltip" title="Changer le statut : Administrateur" onclick="window.location='{{path("ProjetAAdminBundle_admin", { 'username': user.username })}}'">
                                    <span class="icon small white" data-icon="W"></span>
                                </button>
                            {% endif %}
                        {% endif %}
                    </td>
                </tr>
        {% else %}
            <tr>
                <td>No users found</td>
            </tr>
        {% endfor %}
            <tr>
                <td><a href="{{ path('ProjetAAdminBundle_homepage') }}" class="btn medium blue"><span class="icon small white" data-icon=":"></span> Retour</a></td>
            </tr>
        </table>
    </div>
</div>
{% endblock body %}
